
import 'package:intl/intl.dart';
import 'package:ykfextension/ykfextension_datetime.dart';

extension YKExtensionString on String {

  String? toDate({String formatStr = "yyyy-MM-dd HH:mm"}) {
    try {
      int microsecond = int.parse(this) * 1000;
      DateTime dateTime = new DateTime.fromMillisecondsSinceEpoch(microsecond);
      return dateTime.format(formatStr: formatStr);
    } catch (e) {
      return null;
    }
  }
}